function [ v_square_mean,y_mean,grade_mean,z_counter] = TakeMeasurements( stream,y_mean,v_square_mean,grade_mean,z_counter,mass )
% caculated the total drag force and take the average 

%-------------------------TUNNING FACTORS----------------------------------
Eff=0.96;
%--------------------------------------------------------------------------

v = stream(2)*1609.34/3600; % Convert velocity unit to m/s
accel = stream(3);                 % Acceleration
w_e = stream(4)*2*pi/60;           % Convert Engine speed unit to rad/60
t_e = stream(5);                   % Engine Torque at Wheel
grade = stream(6)/100 ;            % Convert road grade unit from % to 1

f_w = t_e*w_e*Eff/v;           % Engine force at wheel (N)
f_i = mass*accel;                     % Inercial force (N)
f_g = mass*grade*9.80665;             % Grade force (N)
y = f_w - f_i -f_g;             
v_square=v*v; 

% absolute value of road grade
grade=abs(grade);
if InputAssertion(v_square,y,f_w,accel,grade) % check if the input is in reasonalbe range
                
   %Recursive Average Filter
   [y_mean,z_counter]=RecursiveAverage(y,y_mean,z_counter);
   [v_square_mean,z_counter]=RecursiveAverage(v_square,v_square_mean,z_counter);
   [grade_mean,z_counter]=RecursiveAverage(grade,grade_mean,z_counter);

end
end

